//
//  SearchReGeocodeResultModel.m
//  o_amap
//
//  Created by Q神 on 2021/4/19.
//

#import "SearchReGeocodeResultModel.h"

@implementation SearchReGeocodeResultModel

+ (SearchReGeocodeResultModel *)createSearchReGeocodeResultModelWithResponse:(AMapReGeocodeSearchResponse *)response {
    SearchReGeocodeResultModel *reGeocodeResultModel = [[SearchReGeocodeResultModel alloc] init];
    
    reGeocodeResultModel.regeocodeAddress = [RegeocodeAddressModel createRegeocodeAddressModelWithResponse:response];
    reGeocodeResultModel.regeocodeQuery = [RegeocodeQueryModel createRegeocodeQueryModelWithResponse:response];
    return reGeocodeResultModel;
}

@end


@implementation RegeocodeAddressModel

+ (RegeocodeAddressModel *)createRegeocodeAddressModelWithResponse:(AMapReGeocodeSearchResponse *)response {
    RegeocodeAddressModel *regeocodeAddressModel = [[RegeocodeAddressModel alloc] init];
    
    regeocodeAddressModel.formatAddress = response.regeocode.formattedAddress;
    regeocodeAddressModel.adCode = [response.regeocode.addressComponent adcode];
    regeocodeAddressModel.building = [response.regeocode.addressComponent building];
    regeocodeAddressModel.city = [response.regeocode.addressComponent city];
    regeocodeAddressModel.cityCode = [response.regeocode.addressComponent citycode];
    regeocodeAddressModel.country = [response.regeocode.addressComponent country];
    regeocodeAddressModel.countryCode = [response.regeocode.addressComponent countryCode];
    regeocodeAddressModel.district = [response.regeocode.addressComponent district];
    regeocodeAddressModel.neighborhood = [response.regeocode.addressComponent neighborhood];
    regeocodeAddressModel.province = [response.regeocode.addressComponent province];
    regeocodeAddressModel.towncode = [response.regeocode.addressComponent towncode];
    regeocodeAddressModel.township = [response.regeocode.addressComponent township];
    regeocodeAddressModel.businessAreas = [BusinessAreasModel createBusinessAreasModelWithArray:[response.regeocode.addressComponent businessAreas]];
    regeocodeAddressModel.streetNumber = [StreetNumberModel createStreetNumberModelWithData:[response.regeocode.addressComponent streetNumber]];

    return regeocodeAddressModel;
}

@end


@implementation RegeocodeQueryModel

+ (RegeocodeQueryModel *)createRegeocodeQueryModelWithResponse:(AMapReGeocodeSearchResponse *)response {
    RegeocodeQueryModel *regeocodeQueryModel = [[RegeocodeQueryModel alloc] init];
    
    return regeocodeQueryModel;
}

@end


@implementation AoiModel

@end


@implementation BusinessAreasModel

+ (NSArray<BusinessAreasModel *> *)createBusinessAreasModelWithArray:(NSArray<AMapBusinessArea *> *)businessAreas {
    NSMutableArray<BusinessAreasModel *> * arrays = [NSMutableArray array];
    
    for (AMapBusinessArea *area in businessAreas) {
        BusinessAreasModel *model = [[BusinessAreasModel alloc] init];
        model.name = area.name;
        model.centerPoint = [LatLngModel initWithLat:area.location.latitude withLng:area.location.longitude];
        [arrays addObject:model];
    }
    return arrays;
}

@end


@implementation CrossroadModel

@end


@implementation RoadModel

@end


@implementation StreetNumberModel

+ (StreetNumberModel *)createStreetNumberModelWithData:(AMapStreetNumber *)streetNumber {
    StreetNumberModel *model = [[StreetNumberModel alloc] init];
    
    model.direction = streetNumber.direction;
    model.distance = streetNumber.distance;
    model.latLonPoint = [LatLngModel initWithLat:streetNumber.location.latitude withLng:streetNumber.location.longitude];
    model.number = streetNumber.number;
    model.street = streetNumber.street;
    return model;
}

@end

